package com.sxygsj.baselibrary.application

import android.app.Application
import android.content.Context

import com.sxygsj.baselibrary.R
import com.tencent.bugly.Bugly
import com.tencent.bugly.beta.Beta
import com.tencent.mmkv.MMKV
import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext

/**
 * Author: sxygsj
 * Date: 2021/3/1 13:52
 * Description:
 * History:
 */
abstract class BaseApplication: Application() {
    override fun onCreate() {
        super.onCreate()
        //Bugly
        Beta.autoInit = true //自动初始化
        Beta.autoCheckUpgrade = true//自动检查升级
        Beta.upgradeDialogLayoutId = R.layout.upgrade_dialog //自定义升级弹窗
        mainFun()
        GlobalScope.launch{
            Bugly.init(context,"",false)//初始化
            MMKV.initialize(context)//mmkv 初始化
            scopeFun()
        }

    }
    companion object {
        lateinit var context: Context
//        lateinit var mmkv:MMKV
    }
    //主线程执行方法
    abstract fun mainFun()
    //协程中执行方法
    abstract fun scopeFun()

}